//表格默认参数配置
$.extend($.fn.datagrid.defaults,{
    "method": "post",
    "pageList":[20,50,100,200,500],
    "ctrlSelect":false
});

$.extend($.fn.iDatagrid.defaults,{
    "tooltip":true,
    "method": "post",
    "checkOnSelect":true,
    "selectOnCheck":true,
    "ctrlSelect":false,
    "singleSelect":false,
    "loadFilter": BaseUtil.appendFunction($.fn.datagrid.defaults.loadFilter,null,EasyUiUtil.resultToGridData),
    "onLoadSuccess":BaseUtil.appendFunction($.fn.datagrid.defaults.onLoadSuccess,null,function(){
        $(this).datagrid('clearSelections'); //一定要加上这一句，要不然datagrid会记住之前的选择状态，删除时会出问题
        //initToolTip();
    }),
    "onBeforeLoad":BaseUtil.appendFunction($.fn.datagrid.defaults.onLoadSuccess,null,function(params){
        return EasyUiUtil.extendToobarParams(params,$(this).datagrid("options"));
    })
});

//datalist默认参数
$.extend($.fn.datalist.defaults,{

});

//表格树默认参数配置
$.extend($.fn.treegrid.defaults,{
    "toolbar":"#tb",
    "pageList":[20,50,100,200,500],
    "method": "post",
    "rownumbers": true,
    "pageSize":20,
    "nowrap":false,
    "pagination":true,
    "checkOnSelect":true,
    "selectOnCheck":true,
    "ctrlSelect":true,
    "singleSelect":false,
    "loadFilter":EasyUiUtil.resultToTreeGridData,
    "onLoadSuccess":function(){
        $(this).datagrid('clearSelections');
        initTreeGridToolTip($(this));
    },
    "onBeforeLoad":function(params){
        return EasyUiUtil.extendToobarParams(params,$(this).datagrid("options"));
    }
});
$.extend($.fn.iTreegrid.defaults,{
    "method": "post",
    "checkOnSelect":true,
    "selectOnCheck":true,
    "ctrlSelect":true,
    "singleSelect":false,
    "loadFilter": BaseUtil.appendFunction($.fn.treegrid.defaults.loadFilter,null,EasyUiUtil.resultToTreeGridData),
    "onLoadSuccess":BaseUtil.appendFunction($.fn.treegrid.defaults.onLoadSuccess,null,function() {
        $(this).datagrid('clearSelections');
        initTreeGridToolTip($(this));
    })
});

//重写下拉列表默认配置
$.extend($.fn.combobox.defaults,{
    "valueField":"value",
    "textField":"text",
    "editable":false,
    "appendOptions":true,
    "appendData":null,		//表示追加的数据.仅会初始化一次.如果直接进行配置则不能追加option节点的数据
    "type":"json",
    "loader":function(param,success,error){
        var t=$(this);
        var options=t.combobox("options");
        var url=options.url;
        if(url){
            var appendData=options.appendData;
            if(!appendData){
                appendData=[];
                //将原始options追加至扩展数据中
                if(options.appendOptions){
                    var childs=t.children("option");
                    $.each(childs,function(i,o){
                        var d={};
                        var $o=$(o);
                        d[options.textField]=$o.text();
                        d[options.valueField]=$o.val();
                        appendData.push(d);
                    });
                }
                options.appendData=appendData;
            }
            if(BaseUtil.checkValue(appendData)&&(!BaseUtil.isArray(appendData))){
                appendData=EasyUiUtil.objectToValueList(appendData,options.valueField,options.textField);
            }
            appendData=appendData||[];
            BaseUtil.doPost(url,param,function(msg,data){
                var resultData=BaseUtil.getResultDataList(data);
                var data=appendData;
                for(var i=data.length-1;i>=0;i--){
                    data[i][options.textField]=data[i][options.textField]||data[i]["label"]||"";
                    data[i][options.valueField]=data[i][options.valueField]||data[i]["value"]||"";
                    resultData.unshift(data[i]);
                }
                success(resultData);
                return false;
            },function(){

            });
        }
    },
    "loadFilter":EasyUiUtil.resultValueSourceToComboData
});


//修改文件上传框默认值
$.extend($.fn.filebox.defaults,{
    "buttonText":"选择文件"
});

//扩展combobox请求参数的值
$.extend($.fn.combobox.defaults,{
    "onBeforeLoad":function(param){
        EasyUiUtil.expandParamValue(param);
    }
});
$.extend($.fn.combotree.defaults,{
    "onBeforeLoad":function(param){
        EasyUiUtil.expandParamValue(param);
    }
});
$.extend($.fn.combogrid.defaults,{
    "onBeforeLoad":function(param){
        EasyUiUtil.expandParamValue(param);
    }
});
$.extend($.fn.combotreegrid.defaults,{
    "onBeforeLoad":function(param){
        EasyUiUtil.expandParamValue(param);
    }
});

$.extend($.fn.datebox.defaults,{
    "editable":true,
    "parser": function(a) {
        if(!a)return new Date();
        if(a.length>4&&a.indexOf("-")==-1&&a.indexOf("/")==-1){
            a=a.substring(0,4)+"-"+(a.substring(4,6)||"01")+"-"+(a.substring(6,8)||"01");
        }
        var b = Date.parse(a);
        return isNaN(b) ? new Date : new Date(b)
    }
});

$.extend($.fn.iDatebox.defaults,{
    "editable":true,
    "parser": function(a) {
        if(!a)return new Date();
        if(a.length>4&&a.indexOf("-")==-1&&a.indexOf("/")==-1){
            a=a.substring(0,4)+"-"+(a.substring(4,6)||"01")+"-"+(a.substring(6,8)||"01");
        }
        var b = Date.parse(a);
        return isNaN(b) ? new Date : new Date(b)
    }
});
if($.fn.datebox) {
    $.fn.datebox.defaults.inputEvents={keydown:function(e){
            var _8ea=e.data.target;
            var t=$(_8ea);
            var opts=t.datebox('options');
            KeyDown(this,e,opts);
            var _8eb=t.data('combo');
            _8eb.timer=setTimeout(function(){
                if(typeof $.data(t[0],'datebox') != 'undefined') {
                    var q=t.combo('getText');
                    if(_8eb.previousText!=q){
                        _8eb.previousText=q;
                        opts.keyHandler.query.call(_8ea,q,e);
                        t.combo('validate');
                    }
                }
            },opts.delay);
        },drop:function(e){
        }};
    //按键常量
    function KeyDown(objTextBox,event,options){
        var KEY = {
            BACKSPACE: 8,
            TAB: 9,
            ENTER: 13,
            END: 35,
            HOME: 36,
            LEFT: 37,
            RIGTH: 39,
            DEL: 46
        };
        var nKeyCode = event.keyCode;
        // 特殊处理的按键
        switch(nKeyCode){
            case KEY.TAB:
            case KEY.HOME:
            case KEY.END:
            case KEY.LEFT:
            case KEY.RIGTH:
                return;
            case KEY.ENTER:
                event.preventDefault();
                if(options.EnterMoveToNext) event.keyCode = 9;
                return;
        }
        //只读就不执行任何操作
        if(objTextBox.ReadOnly) {
            event.returnValue = false;
            return;
        }
        // 当前文本框中的文本
        var strText =objTextBox.value;
        // 文本长度
        var nTextLen=strText.length;
        // 当前光标位置
        var nCursorPos = GetCursor(objTextBox).start;
        //忽略按键
        event.returnValue = false;
        //阻止冒泡
        event.preventDefault();
        // 自行处理按钮
        switch (nKeyCode) {
            case KEY.BACKSPACE:
                if(nCursorPos > 0) {
                    fronttext = strText.substr(nCursorPos - 1,1);
                    if(fronttext!='-' && fronttext!=':' && fronttext!=' ') {
                        fronttext='0';
                        strText = strText.substr(0,nCursorPos - 1) + fronttext + strText.substr(nCursorPos, nTextLen-nCursorPos);
                    }
                    nCursorPos--;
                } else {
                    strText = "";
                }
                break;
            case KEY.DEL:
                if(nCursorPos<nTextLen) {
                    behindtext = strText.substr(nCursorPos,1);
                    if(behindtext!='-' && behindtext!=':' && behindtext!=' ') behindtext='0';
                    if(nCursorPos + 1 == nTextLen)
                        strText = strText.substr(0,nCursorPos) + behindtext;
                    else
                        strText = strText.substr(0,nCursorPos) + behindtext + strText.substr(nCursorPos+1,nTextLen-nCursorPos-1);
                    nCursorPos++;
                }
                break;
            default :
                if(!(nKeyCode >=48 && nKeyCode<=57 || nKeyCode >=96 && nKeyCode<=105)) break;
                if(nCursorPos==nTextLen&&nTextLen>0) break;
                if (nKeyCode > 95) nKeyCode -= (95-47);
                if(nTextLen==0) {
                    strText=String.fromCharCode(nKeyCode)+'000-01-01';
                    nCursorPos++;
                }else{
                    behindtext = strText.substr(nCursorPos,1);
                    if(behindtext!='-' && behindtext!=':' && behindtext!=' ') {
                        var keycode = String.fromCharCode(nKeyCode);
                        preText = strText.substr(0,nCursorPos) + keycode + strText.substr(nCursorPos+1,nTextLen);
                        if(!DealWith(preText,nCursorPos)) break;
                        strText = preText;
                        nCursorPos++;
                    }
                    if (nCursorPos>strText.length) {
                        nCursorPos=strText.length;
                    }
                    //输入后,要根据当前位置决定是否要调整位置。比如碰到":"  "-"  " "
                    if(nCursorPos==4 || nCursorPos==7 || nCursorPos==10 || nCursorPos==13 || nCursorPos==16) nCursorPos++;
                }
                break;
        }
        objTextBox.value = strText;
        objTextBox.setSelectionRange(nCursorPos,nCursorPos);
    };

    function DealWith(input,nCursorPos){
        var ls_date;
        ls_year = input.substr(0,4);
        if(ls_year=='0000') ls_year = '2001';
        ls_month = input.substr(5,2);
        if(ls_month=='00') ls_month = '01';
        ls_day = input.substr(8,2);
        if(ls_day=='00') ls_day = '01';
        ls_date = ls_year +'-'+ ls_month +'-'+ ls_day;
        //光标所在的位置进行判断当前字符串是否合法
        return isValidDate(ls_date);
    }

    function GetCursor(textBox){
        var obj = new Object();
        var start = 0,end = 0;
        if (/firefox/.test(navigator.userAgent.toLowerCase()) || /chrome/.test(navigator.userAgent.toLowerCase())) {
            start = textBox.selectionStart;
            end = textBox.selectionEnd;
        }
        if (/msie/.test(navigator.userAgent.toLowerCase())) {
            var range=textBox.createTextRange();
            var text = range.text;
            var selrange = document.selection.createRange();
            var seltext = selrange.text;
            while(selrange.compareEndPoints('StartToStart',range)>0){
                selrange.moveStart('character',-1);
                start ++;
            }
            while(selrange.compareEndPoints('EndToStart',range)>0){
                selrange.moveEnd('character',-1);
                end ++;
            }
        }
        obj.start = start;
        obj.end = end;
        return obj;
    }

    //是否为日期
    function isValidDate(strDate)
    {
        var ls_regex = '^((((((0[48])|([13579][26])|([2468][048]))00)|([0-9][0-9]((0[48])|([13579][26])|([2468][048]))))-02-29)|(((000[1-9])|(00[1-9][0-9])|(0[1-9][0-9][0-9])|([1-9][0-9][0-9][0-9]))-((((0[13578])|(1[02]))-31)|(((0[1,3-9])|(1[0-2]))-(29|30))|(((0[1-9])|(1[0-2]))-((0[1-9])|(1[0-9])|(2[0-8]))))))$';
        var exp = new RegExp(ls_regex, 'i');
        return exp.test(strDate);
    }

    //是否为时间
    function isValidTime(strTime)
    {
        var a = strTime.match(/^(\d{2,2})(:)?(\d{2,2})\2(\d{2,2})$/);
        if (!a || a[1]>23 || a[3]>59 || a[4]>59) return false;
        return true;
    }

    function getDateTime(options)
    {
        var d = new Date();
        var vYear = d.getFullYear();
        var vMon = d.getMonth() + 1;
        vMon = (vMon<10 ? '0' + vMon : vMon);
        var vDay = d.getDate();
        var ls_date = vYear+'-'+vMon+'-'+(vDay<10 ? '0'+ vDay : vDay );
        return options.isnow?ls_date:(vYear+'-'+vMon+'-'+'01');

    }
}

$.extend($.fn.validatebox.defaults.rules,{
    account:{
        validator:function(value,param){
            return /^\w{4,20}$/.test(value);
        },
        message:"账号格式错误"
    },
    password:{
        validator:function(value,param){
            return /^\w{4,20}$/.test(value);
        },
        message:"密码格式错误"
    },
    dateBefore:{	//日期需要先于,参数(名称/选择器/日期字符串等等,是否包含当天)
        validator:function(value,param){
            try{
                value=$.trim(value);
                if(!BaseUtil.isDate(value))return false;
                var name=param[0];
                var date="";
                if(BaseUtil.isDate(name))date=name;
                else{
                    try{
                        date=EasyUiUtil.getValue(name);
                    }catch(ee){
                        //如果抛出了异常,则直接返回true,因为可能指定的组件还未加载
                        console.log("datatime textbox dataBefore validator has exception:%o",ee);
                        return true;
                    }
                }
                if(!date)return true;
                return param[0]?(value<=date):(value<date);
            }catch(e){
                console.trace("datatime textbox dataBefore validator has exception:%o",e);
                return false;
            }
        },
        message:"日期错误"
    },
    dateAfter:{		//日期需要后于,参数(名称/选择器/日期字符串等等,是否包含当天)
        validator:function(value,param){
            try{
                value=$.trim(value);
                if(!BaseUtil.isDate(value))return false;
                var name=param[0];
                var date="";
                if(BaseUtil.isDate(name))date=name;
                else{
                    try{
                        date=EasyUiUtil.getValue(name);
                    }catch(ee){
                        //如果抛出了异常,则直接返回true,因为可能指定的组件还未加载
                        console.log("datatime textbox dataBefore validator has exception:%o",ee);
                        return true;
                    }
                }
                if(!date)return true;
                return param[0]?(value>=date):(value>date);
            }catch(e){
                console.trace("datatime textbox dataBefore validator has exception:%o",e);
                return false;
            }
        },
        message:"日期错误"
    },
    dataAfterNow:{	//日期后于今天,参数(是否包含今天)
        validator:function(value,param){
            value=$.trim(value);
            if(!BaseUtil.isDate(value))return false;
            var now=new Date().format("yyyy-MM-dd");
            return param[0]?(value>=now):(value>now);
        },
        message:"日期必须大于今天"
    },
    decimal:{	//数字,小数或整数
        validator:function(value,param){
            value=$.trim(value);
            if(!value)return true;
            if(!param)param=[];
            var len=param[0]||3;
            var reg="^([0-9]{1,}([.][0-9]{1,{}})?)$".format(len);
            return new RegExp(reg).test(value);
        },
        message:"整数或小数格式错误"
    },
    datevalid:{	//日期是,有效的日期
        validator:function(value,param){
            value=$.trim(value);
            if(!value)return true;
            if(value.length>4&&value.indexOf("-")==-1&&value.indexOf("/")==-1){
                value=value.substring(0,4)+"-"+(value.substring(4,6)||"01")+"-"+(value.substring(6,8)||"01");
            }
            var d = Date.parse(value);
            if(isNaN(d))return false;
            //日期必须在1970-2099之间
            var date=new Date(d);
            if(date.getFullYear()<1970||date.getFullYear()>2099)return false;
            return true;
        },
        message:"输入日期值超出范围"
    },
    ip:{
        validator:function(value,param){
            return /^(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])\.(\d{1,2}|1\d\d|2[0-4]\d|25[0-5])$/.test(value);
        },
        message:"IP格式错误"
    },
    json:{ // 验证是否为JSON格式数据
        validator:function(value,param){
            try {
                var obj=JSON.parse(value);
                if(typeof obj == 'object' && obj ){
                    return true;
                }else{
                    return false;
                }
            } catch (err) {
                return false
            }
        },
        message:"JSON数据格式错误"
    }
});

$.extend($.fn.numberbox.defaults,{
    "groupSeparator":""
});
$.extend($.fn.iNumberbox.defaults,{
    "groupSeparator":""
});

/*********扩展开始********/

/**
 * 组件方法和参数扩展进行扩展
 */
$.extend($.fn.datagrid.defaults,{
    selectLoadFilter:null,		//函数,接收(result)表示远程返回的JSON数据,该方法需要返回 (ID数组)/(false跳过后续执行)
    selectUrl:""				//字符串或者函数,  函数 返回字符串/{url:"",data:""} 格式对象  url中支持{name}方式取值
});
/**
 * 仅需对datagrid进行扩展
 */
$.extend($.fn.datagrid.methods,{
    reloadSelect:function(jq,keep){	//keep表示是否保留原来的选择
        var t=BaseUtil.getJQuery(jq);
        var opts=t.datagrid("options");
        EasyUiUtil.selectGridByUrl(t,opts.selectUrl,{},opts.selectLoadFilter,"auto");
    },
    /**
     * 开打提示功能
     * @param {} jq
     * @param {} params 提示消息框的样式
     * @return {}
     */
    doCellTip:function (jq, params) {
        function showTip(showParams, td, e, dg) {
            //无文本，不提示。
            if ($(td).text() == "") return;

            params = params || {};
            var options = dg.data('datagrid');
            showParams.content = '<div class="tipcontent">' + showParams.content + '</div>';
            $(td).tooltip({
                content:showParams.content,
                trackMouse:true,
                position:params.position,
                onHide:function () {
                    $(this).tooltip('destroy');
                },
                onShow:function () {
                    var tip = $(this).tooltip('tip');
                    if(showParams.tipStyler){
                        tip.css(showParams.tipStyler);
                    }
                    if(showParams.contentStyler){
                        tip.find('div.tipcontent').css(showParams.contentStyler);
                    }
                }
            }).tooltip('show');

        };
        return jq.each(function () {
            var grid = $(this);
            var options = $(this).data('datagrid');
            if (!options.tooltip) {
                var panel = grid.datagrid('getPanel').panel('panel');
                panel.find('.datagrid-body').each(function () {
                    var delegateEle = $(this).find('> div.datagrid-body-inner').length ? $(this).find('> div.datagrid-body-inner')[0] : this;
                    $(delegateEle).undelegate('td', 'mouseover').undelegate('td', 'mouseout').undelegate('td', 'mousemove').delegate('td[field]', {
                        'mouseover':function (e) {
                            //if($(this).attr('field')===undefined) return;
                            var that = this;
                            var setField = null;
                            if(params.specialShowFields && params.specialShowFields.sort){
                                for(var i=0; i<params.specialShowFields.length; i++){
                                    if(params.specialShowFields[i].field == $(this).attr('field')){
                                        setField = params.specialShowFields[i];
                                    }
                                }
                            }
                            if(setField==null){
                                options.factContent = $(this).find('>div').clone().css({'margin-left':'-5000px', 'width':'auto', 'display':'inline', 'position':'absolute'}).appendTo('body');
                                var factContentWidth = options.factContent.width();
                                params.content = $(this).text();
                                if($(this).length > 0) {
                                    var outerHTML = $(this)[0].outerHTML;
                                    if(outerHTML.length > 20) {
                                        if(outerHTML.substring(0,20) == '<td field="operate">') {
                                            return;
                                        }
                                    }
                                }
                                if (params.onlyShowInterrupt) {
                                    if (factContentWidth + 14 > $(this).width()) {
                                        showTip(params, this, e, grid);
                                    }
                                } else {
                                    showTip(params, this, e, grid);
                                }
                            }else{
                                panel.find('.datagrid-body').each(function(){
                                    var trs = $(this).find('tr[datagrid-row-index="' + $(that).parent().attr('datagrid-row-index') + '"]');
                                    trs.each(function(){
                                        var td = $(this).find('> td[field="' + setField.showField + '"]');
                                        if(td.length){
                                            params.content = td.text();
                                        }
                                    });
                                });
                                showTip(params, this, e, grid);
                            }
                        },
                        'mouseout':function (e) {
                            if (options.factContent) {
                                options.factContent.remove();
                                options.factContent = null;
                            }
                        }
                    });
                });
            }
        });
    },
    /**
     * 关闭消息提示功能
     * @param {} jq
     * @return {}
     */
    cancelCellTip:function (jq) {
        return jq.each(function () {
            var data = $(this).data('datagrid');
            if (data.factContent) {
                data.factContent.remove();
                data.factContent = null;
            }
            var panel = $(this).datagrid('getPanel').panel('panel');
            panel.find('.datagrid-body').undelegate('td', 'mouseover').undelegate('td', 'mouseout').undelegate('td', 'mousemove');
        });
    }
});




/**
 * 扩展iframe弹出.存在问题.多次调用时存在问题
 */
(function(){

    if(!$.fn.dialog.optionProxy){
        $.fn.dialog.optionProxy=true;		//是否已经代理参数转换

        var rawParser=$.fn.dialog.parseOptions;
        var iframeText='<iframe src="{}" width="100%" height="100%" frameborder="0" scrolling="no" style="box-sizing: border-box;"></iframe>';

        //代理参数转换
        $.fn.dialog.parseOptions=function(jq){
            var opts=rawParser.apply(jq,Array.prototype.slice.call(arguments));
            if((opts["useIframe"]=="true"||opts["useIframe"]==true)&&opts["href"]){
                opts.content=iframeText.format(opts["href"]);
                opts.href=null;
            }
            return opts;
        };
        //刷新iframe中的内容.通过iframe刷新content的内容.
        $.fn.dialog.methods.refreshIframe=function(jq,href){
            var content=null;
            if(href)content=iframeText.format(href);
            return jq.each(function(){
                var t=$(this);
                var opts=t.dialog("options");

                opts.content=content||opts.content;
                opts.href=null;
                return t.dialog({
                    "content":opts.content
                });
            });
        }
    }
})();


$(window).resize(function(){
    initToolTip();
    initTreeGridToolTip();
});

function initToolTip(girdObj){
    var defaultGirdObj = '#maingrid';
    girdObj = girdObj?girdObj:defaultGirdObj;
    $(girdObj).datagrid('doCellTip',{onlyShowInterrupt:true,tipStyler:{padding:'3px 10px'}});
}

function initTreeGridToolTip(girdObj){
    return;
    var defaultGirdObj = '#sprojecttransfertreegrid';
    girdObj = girdObj?girdObj:defaultGirdObj;
    $(girdObj).treegrid('doCellTip',{onlyShowInterrupt:true,tipStyler:{padding:'3px 10px'}});
}

/**
 * 对treegrid进行扩张
 */
$.extend($.fn.treegrid.methods,{
    /**
     * 开打提示功能
     * @param {} jq
     * @param {} params 提示消息框的样式
     * @return {}
     */
    doCellTip:function (jq, params) {
        function showTip(showParams, td, e, dg) {
            //无文本，不提示。
            if ($(td).text() == "") return;

            params = params || {};
            var options = dg.data('datagrid');
            showParams.content = '<div class="tipcontent">' + showParams.content + '</div>';
            $(td).tooltip({
                content:showParams.content,
                trackMouse:true,
                position:params.position,
                onHide:function () {
                    $(this).tooltip('destroy');
                },
                onShow:function () {
                    var tip = $(this).tooltip('tip');
                    if(showParams.tipStyler){
                        tip.css(showParams.tipStyler);
                    }
                    if(showParams.contentStyler){
                        tip.find('div.tipcontent').css(showParams.contentStyler);
                    }
                }
            }).tooltip('show');

        };
        return jq.each(function () {
            var grid = $(this);
            var options = $(this).data('datagrid');
            if (!options.tooltip) {
                var panel = grid.datagrid('getPanel').panel('panel');
                panel.find('.datagrid-body').each(function () {
                    var delegateEle = $(this).find('> div.datagrid-body-inner').length ? $(this).find('> div.datagrid-body-inner')[0] : this;
                    $(delegateEle).undelegate('td', 'mouseover').undelegate('td', 'mouseout').undelegate('td', 'mousemove').delegate('td[field]', {
                        'mouseover':function (e) {
                            //if($(this).attr('field')===undefined) return;
                            var that = this;
                            var setField = null;
                            if(params.specialShowFields && params.specialShowFields.sort){
                                for(var i=0; i<params.specialShowFields.length; i++){
                                    if(params.specialShowFields[i].field == $(this).attr('field')){
                                        setField = params.specialShowFields[i];
                                    }
                                }
                            }
                            if(setField==null){
                                options.factContent = $(this).find('>div').clone().css({'margin-left':'-5000px', 'width':'auto', 'display':'inline', 'position':'absolute'}).appendTo('body');
                                var factContentWidth = options.factContent.width();
                                params.content = $(this).text();
                                if($(this).length > 0) {
                                    var outerHTML = $(this)[0].outerHTML;
                                    if(outerHTML.length > 20) {
                                        if(outerHTML.substring(0,20) == '<td field="operate">') {
                                            return;
                                        }
                                    }
                                }
                                if (params.onlyShowInterrupt) {
                                    if (factContentWidth + 14 > $(this).width()) {
                                        showTip(params, this, e, grid);
                                    }
                                } else {
                                    showTip(params, this, e, grid);
                                }
                            }else{
                                panel.find('.datagrid-body').each(function(){
                                    var trs = $(this).find('tr[datagrid-row-index="' + $(that).parent().attr('datagrid-row-index') + '"]');
                                    trs.each(function(){
                                        var td = $(this).find('> td[field="' + setField.showField + '"]');
                                        if(td.length){
                                            params.content = td.text();
                                        }
                                    });
                                });
                                showTip(params, this, e, grid);
                            }
                        },
                        'mouseout':function (e) {
                            if (options.factContent) {
                                options.factContent.remove();
                                options.factContent = null;
                            }
                        }
                    });
                });
            }
        });
    },
    /**
     * 关闭消息提示功能
     * @param {} jq
     * @return {}
     */
    cancelCellTip:function (jq) {
        return jq.each(function () {
            var data = $(this).data('datagrid');
            if (data.factContent) {
                data.factContent.remove();
                data.factContent = null;
            }
            var panel = $(this).datagrid('getPanel').panel('panel');
            panel.find('.datagrid-body').undelegate('td', 'mouseover').undelegate('td', 'mouseout').undelegate('td', 'mousemove');
        });
    }
});

/****************************** 扩展改变文本值，文本样式改变颜色 begin ***************************/
/*if ($.fn.textbox){
	$.fn.textbox.defaults.inputEvents.change=function(e){
		var t=$(e.data.target);
		t.textbox('textbox').addClass('changetext');
	};
}

if ($.fn.combo){
	$.fn.combo.defaults.inputEvents.change=function(e){
		var t=$(e.data.target);
		t.textbox('textbox').addClass('changetext');
	};
}

if ($.fn.combobox){
	$.fn.combobox.defaults.onChange=function(newValue,oldValue){
		t.textbox('combobox').addClass('changetext');
	};

	$.fn.combobox.defaults.inputEvents.change=function(newValue,oldValue){
		t.textbox('combobox').addClass('changetext');
	};
}

if ($.fn.numberbox){
	$.fn.numberbox.defaults.inputEvents.change=function(e){
		var t=$(e.data.target);
		t.textbox('textbox').addClass('changetext');
	};
}

if ($.fn.datebox){
	$.fn.datebox.defaults.onChange=function(newVal,oldVal) {
		if(newVal != null) {
			var t=$(this);
			t.textbox('textbox').addClass('changetext');
		}
	};
}

if ($.fn.form.defaults) {
	$.fn.form.defaults.onLoadSuccess=BaseUtil.appendFunction($.fn.form.defaults.onLoadSuccess,null,function(t) {
		$(this).find('.changetext').each(function(i,n) {
			$(this).removeClass('changetext');
		});
	});
}*/

/****************************** 扩展改变文本值，文本样式改变颜色 end ***************************/








